Trend AngleIntroduction:
In today's post, we'll dive deep into the source code of a unique trading tool, the Trend Angle Indicator. The script is an indicator that calculates the trend angle for a given financial instrument. This powerful tool can help traders identify the strength and direction of a trend, allowing them to make informed decisions.
Overview of the Trend Angle Indicator:
The Trend Angle Indicator calculates the trend angle based on the slope of the price movement over a specified period. It uses an Exponential Moving Average (EMA) to smooth the data and an Epanechnikov kernel function for additional smoothing. The indicator provides a visual representation of the trend angle, making it easy to interpret for traders of all skill levels.
Let's break down the key components of the script:
Inputs:
Length: The number of periods to calculate the trend angle (default: 8)
Scale: A scaling factor for the ATR (Average True Range) calculation (default: 2)
Smoothing: The smoothing parameter for the Epanechnikov kernel function (default: 2)
Smoothing Factor: The radius of the Epanechnikov kernel function (default: 1)
Functions:
ema(): Exponential Moving Average calculation
atan2(): Arctangent function
degrees(): Conversion of radians to degrees
epanechnikov_kernel(): Epanechnikov kernel function for additional smoothing
Calculations:
atr: The EMA of the True Range
slope: The slope of the price movement over the given length
angle_rad: The angle of the slope in radians
degrees: The smoothed angle in degrees
Plotting:
Trend Angle: The trend angle, plotted as a line on the chart
Horizontal lines: 0, 90, and -90 degrees as reference points
How the Trend Angle Indicator Works:
The Trend Angle Indicator begins by calculating the Exponential Moving Average (EMA) of the True Range (TR) for a given financial instrument. This smooths the price data and provides a more accurate representation of the instrument's price movement.
Next, the indicator calculates the slope of the price movement over the specified length. This slope is then divided by the scaled ATR to normalize the trend angle based on the instrument's volatility. The angle is calculated using the atan2() function, which computes the arctangent of the slope.
The final step in the process is to smooth the trend angle using the Epanechnikov kernel function. This function provides additional smoothing to the trend angle, making it easier to interpret and reducing the impact of short-term price fluctuations.
Conclusion:
The Trend Angle Indicator is a powerful trading tool that allows traders to quickly and easily determine the strength and direction of a trend. By combining the Exponential Moving Average, ATR, and Epanechnikov kernel function, this indicator provides an accurate and easily interpretable representation of the trend angle. Whether you're an experienced trader or just starting, the Trend Angle Indicator can provide valuable insights into the market and help improve your trading decisions.
Search in scripts for "THE SCRIPT"
Optimized Logarithmic Curve for Bitcoin (BTC/USD) by FICASHello everyone!
I'd like to share with you a handy tool that is incredibly useful for analyzing Bitcoin's price movements. This optimized logarithmic curve indicator is a refined version of the popular "My BTC log curve" indicator, originally created by @quantadelic.
We have made several improvements to enhance its predictive capabilities when it comes to identifying potential price bottoms for Bitcoin BTC/USD.
Description:
In this detailed analysis, we are excited to introduce you to an optimized version of the popular "My BTC log curve" indicator, originally created by @quantadelic. We have refined the indicator for enhanced predictive capabilities when it comes to identifying potential price bottoms for Bitcoin BTC/USD. By putting ourselves in the reader's shoes, we aim to provide a comprehensive and meaningful explanation of our analysis and predictions using this improved tool.
The logarithmic curve is a powerful tool for analyzing price movements in a non-linear fashion, allowing traders and investors to identify critical turning points and trends. With the optimized logarithmic curve, we can more accurately predict potential price bottoms, ultimately guiding better-informed trading and investment decisions.
Key Features of the Optimized Logarithmic Curve:
Improved predictive capabilities: The refined logarithmic curve has been optimized to provide more accurate predictions of potential price bottoms, enabling traders to make better-informed decisions.
Enhanced visualization: The optimized curve offers a clearer visual representation of Bitcoin's price movements, making it easier for traders to identify patterns and trends.
Adaptability: This indicator can be applied to various timeframes, providing insights for both short-term and long-term traders.
The optimized logarithmic curve indicator is based on a logarithmic regression of the USD price of Bitcoin, calculated according to the equation:
y = A * exp(beta * x^lambda + c) + m * x + b
where x is the number of days since the genesis block. All parameters are editable in the script options, allowing traders to customize the curve to their preferences.
Here are some of the key changes made to the original indicator to create the optimized logarithmic curve:
Midline Calculation: The optimized logarithmic curve utilizes an updated method for calculating the midline, which better represents the average price movement of Bitcoin over time. This improved midline calculation provides a more accurate representation of Bitcoin's historical price trajectory, making it easier to identify potential price bottoms.
Cross Line Calculation: We have modified the way cross lines are calculated in the optimized logarithmic curve. These new cross lines are derived from a combination of the updated midline calculation and historical support and resistance levels. This change allows traders to more accurately identify critical points in the market where price action is likely to reverse or continue its trend.
Table Display: a powerful visualization tool designed to provide a comprehensive overview of the relationships between various exponential curves and the Bitcoin price. This table display, integrated into the "FiCAS BTC log curve" indicator, enables traders and analysts to quickly compare and assess the impact of these curves on the market.
Our analysis using the optimized logarithmic curve suggests that Bitcoin might be at a critical price bottom, indicating that selling at this point may not be the most prudent course of action. Instead, traders and investors could consider taking advantage of the potential upswing as the market moves away from the identified price bottom.
Key highlights of this Optimized Logarithmic Curve for Bitcoin (BTC/USD) by FICAS:
Custom Pine Script: Pinescript code serves as the backbone of this strategy, providing a strong foundation for identifying potential opportunities based on the relationships between exponential curves and Bitcoin price.
MACD Indicator: The Moving Average Convergence Divergence (MACD) is integrated to help traders recognize trend reversals, bullish or bearish market conditions, and potential entry or exit points.
Momentum Indicator: By incorporating the Momentum (10, close) indicator, traders can identify the strength of price movements and potential trend continuations or reversals.
RSI and SMA: The Relative Strength Index (RSI) is used to assess overbought or oversold conditions, while the Simple Moving Average (SMA) with a period of 14 and an applied factor of 2 smoothens the data for better trend identification.
IMPORTANT:
While this indicator can be applied to traditional BTC/USD charts, we highly recommend using it on the following chart for optimal results in identifying price bottoms:
BITSTAMP:BTCUSD / CRYPTOCAP:BTC.D * 100
By employing the optimized logarithmic curve indicator on the recommended chart, traders can gain a more accurate perspective on potential price bottoms, leading to improved decision-making.
In conclusion, the optimized logarithmic curve indicator provides valuable insights into Bitcoin's price movements, allowing traders and investors to make more informed decisions. We encourage you to test this refined tool and share your thoughts in the comments section. Special thanks to @quantadelic, the first creator of this indicator, for inspiring us to develop this optimized version. If you have any questions or require further clarification, please feel free to ask. Wishing you success in your trading and investment endeavors!
Please ensure you understand and abide by the TradingView House Rules when using this indicator: www.tradingview.com
EMA CO AlertEMAs play an important role in identifying the mood of the market.
Frequently used short term EMA is 5 and long term EMA is 50.
This script detects the crossover (+ve and -ve) and generates alerts accordingly.
Steps to apply:
1) Open the script on a desired timeframe.
2) Add this indicator on the chart
3) Choose the values of the 2 EMAs from settings
4) Go to the alert window.
5) Select this indicator from the 'Condition' dropdown
6) Create the alert.
This alert will then run in the background and notify you.
Need to apply a one time alert on the scripts.
In addition to above, you can also add this indicator on the chart and it will show green/red lines on the chart for signals.
Fibonacci compressionThis script will search x-bars back, if it can find a triangle formation that meets certain Fibonacci ratios.
Based on the trend-based fib extension tool from the first high to the first low and then the 2nd high (in a bullish structure, inverse for bearish), we can predict the take profit levels.
The main target is the 0.618, first take profit is at the 0.236. In a strong trend, one can aim for the 1 fib ratio.
Once the 3 points are known, the script will already plot the take profit levels. It is better to wait until the full pattern develops with a 2nd lower high and a 2nd higher low.
The way I use it, is closing 20% at TP1, 80% of the remainder at TP2 and final close out at TP3.
Stop loss is the red line which will show up after a full pattern is formed.
Plot out the profit levels with the trend based fib extension tool, because once there's a break-out of the pattern, the script won't show the compression any more. (or use the replay button to go back in time to plot it again)
The volume label will appear once there's a divergence between the low and higher low or the high and lower high. It is based on my cumulative volume script. It only works well on timeframes above 4 hour, but volume in favor of a short, doesn't always guarantee a good short setup, so don't take it for granted.
It has around a 30 - 33% chance of hitting your TP2, so make sure the risk to reward is at least 3.
Happy trading!
Rolling HTF Liquidity Levels [CHE]█ OVERVIEW
This indicator displays a Rolling HTF Liquidity Levels . Contrary to HTF Liquidity Levels indicators which use a fix time segment, Rolling HTF Liquidity Levels calculates using a moving window defined by a time period (not a simple number of bars), so it shows better results.
This indicator is inspired by
The indicator introduces a new representation of the previous rolling time frame highs & lows (DWM HL) with a focus on untapped levels.
█ CONCEPTS
Untapped Levels
It is popularly known that the liquidity is located behind swing points or beyond higher time frames highs/lows.
Rolling HTF Liquidity Levels uses a moving window, it does not exhibit the static of the HTF Liquidity Levels plots.
█ HOW TO USE IT
Load the indicator on an active chart (see the Help Center if you don't know how).
Time period
By default, the script uses an auto-stepping mechanism to adjust the time period of its moving window to the chart's timeframe. The following table shows chart timeframes and the corresponding time period used by the script. When the chart's timeframe is less than or equal to the timeframe in the first column, the second column's time period is used to calculate the Rolling HTF Liquidity Levels:
Chart Time
timeframe period
1min 🠆 1H
5min 🠆 4H
1H 🠆 1D
4H 🠆 3D
12H 🠆 1W
1D 🠆 1M
1W 🠆 3M
By default, the time period currently used is displayed in the lower-right corner of the chart. The script's inputs allow you to hide the display or change its size and location.
This indicator should make trading easier and improve analysis. Nothing is worse than indicators that give confusingly different signals.
I hope you enjoy my new ideas
best regards
Chervolino
Support Resistance Channels/Zones Multi Time FrameHello All,
For long time I have been getting a lot of requests for Support/Resistance Multi Time Frame script. Here ' Support Resistance Channels/Zones Multi Time Frame ' is in your service.
This script works if the Higher Time Frame you set is higher than the chart time frame. so the time frame in the options should be higher than the chart time frame.
The script checks total bars and highest/lowest in visible part of the chart and shows all S/R zones that fits according the highest/lowest in visible part. you can see screenshots below if it didn't make sense or if you didn't understand
Let see the options:
Higher Time Frame : the time frame that will be used to get Support/Resistance zones, should be higher than chart time frame
Pivot Period : is the number to find the Pivot Points on Higher time frame, these pivot points are used while calculating the S/R zones
Loopback Period : is the number of total bars on higher time frame which is used while finding pivot points
Maximum Channel Width % : is the percent for maximum width for each channel
Minimum Strength : each zone should contain at least a 1 or more pivot points, you set it here. (Open/High/Low/Close also are considered while calculating the strength)
Maximum Number of S/R : the number of maximum Support/Resistance zones. there can be less S/Rs than this number if it can not find enough S/Rs
Show S/R that fits the Chart : because of we use higher time frame, you should enable this option then the script shows only S/Rs that fits the current chart. if you disable this option, all S/R zones are shown and it may shrink the chart. also you may not see any S/R zone if you don't choose the higher time frame wisely ;)
Show S/R channels in a table : if you enable this option (by default it's enabled) then lower/upper bands of all S/R zones shown in a table ( even if it doesn't fit the chart ). you can change its location. zones are sorted according to their strengths. first one is the strongest.
and the other options is about colors and transparency.
Screenshots before and after zoom-out:
after zoom-out number of visible bars and highest/lowest change and it shows more S/R zones that fits the current chart!
if you see Support Resistance zone like below then you should decrease ' Maximum Channel Width ' or you should set higher time frame better:
You can change colors and transparency:
You can change Table location:
Alerts added :)
P.S. I haven't tested it so much, if you see any issue please drop a comment or send me message
Enjoy!
10yr, 20yr, 30yr Averages: Month/Month % Change; SeasonalityCalculates 10yr, 20yr and 30yr averages for month/month % change
~shows seasonal tendencies in assets (best in commodities). In above chart: August is a seasonally bullish month for Gold: All the averages agree. And January is the most seasonally bullish month.
~averages represent current month/previous month. i.e. Jan22 average % change represents whole of jan22 / whole of dec21
~designed for daily timeframe only: I found calling monthly data too buggy to work with, and I thought weekly basis may be less precise (though it would certainly reduce calculation time!)
~choose input year, and see the previous 10yrs of monthly % change readings, and previous 10yrs Average, 20yr Average, 30yr Average for the respective month. Labels table is always anchored to input year.
~user inputs: colors | label sizes | decimal places | source expression for averages | year | show/hide various sections
~multi-yr averges always print, i.e if only 10yrs history => 10yr Av = 20yr Av = 30yr Av. 'History Available' label helps here.
Based on my previously publised script: "Month/Month Percentage % Change, Historical; Seasonal Tendency"
Publishing this as seperate indicator because:
~significantly slower to load (around 13 seconds)
~non-premium users may not have the historical bars available to use 20yr or 30yr averages =>> prefer the lite/speedier version
~~tips~~
~after loading, touch the new right scale; then can drag the table as you like and seperate it from price chart
##Debugging/tweaking##
Comment-in the block at the end:
~test/verifify specific array elements elements.
~see the script calculation/load time
~~other ideas ~~
~could tweak the array.slice values in lines 313 - 355 to show the last 3 consecutive 10yr averages instead (i.e. change 0, 10 | 0,20 | 0, 30 to 0, 10 | 10, 20 | 20,30)
~add 40yr average by adding another block to each of the array functions, and tweaking the respective labels after line 313 (though this would likely add another 5 seconds to the load time)
~use alternative method for getting obtaining multi-year values from individual month elements. I used array.avg. You could try array.median, array.mode, array.variance, array.max, array.min (lines 313-355)
Everything Bitcoin [Kioseff Trading]Hello!
This script retrieves most of the available Bitcoin data published by Quandl; the script utilizes the new request.security_lower_tf() function.
Included statistics,
True price
Volume
Difficulty
My Wallet # Of Users
Average Block Size
api.blockchain size
Median Transaction Confirmation Time
Miners' Revenue
Hash Rate
Cost Per Transaction
Cost % of Transaction Volume
Estimated Transaction Volume USD
Total Output Volume
Number Of Transactions Per Block
# of Unique BTC Addresses
# of BTC Transactions Excluding Popular Addresses
Total Number of Transactions
Daily # of Transactions
Total Transaction Fees USD
Market Cap
Total BTC
Retrieved data can be plotted as line graphs; however, the data is initially split between two tables.
The image above shows how the requested Bitcoin data is displayed.
However, in the user inputs tab, you can modify how the data is displayed.
For instance, you can append the data displayed in the floating statistics box to the stagnant statistics box.
The image above exemplifies the instance.
You can hide any and all data via the user inputs tab.
In addition to data publishing, the script retrieves lower timeframe price/volume/indicator data, to which the values of the requested data are appended to center-right table.
The image above shows the script retrieving one-minute bar data.
Up arrows reflect an increase in the more recent value, relative to the immediately preceding value.
Down arrows reflect a decrease in the more recent value relative to the immediately preceding value.
The ascending minute column reflects the number of minutes/hours (ago) the displayed value occurred.
For instance, 15 minutes means the displayed value occurred 15 minutes prior to the current time (value).
Volume, price, and indicator data can be retrieved on lower timeframe charts ranging from 1 minute to 1440 minutes.
The image above shows retrieved 5-minute volume data.
Several built-in indicators are included, to which lower timeframe values can be retrieved.
The image above shows LTF VWAP data. Also distinguished are increases/decreases for sequential values.
The image above shows a dynamic regression channel. The channel terminates and resets each fiscal quarter. Previous channels remain on the chart.
Lastly, you can plot any of the requested data.
The new request.security_lower_tf() function is immensely advantageous - be sure to try it in your scripts!
Support/Resistance With Breaks & Bounces [MyTradingCoder]This script uses the built-in pivothigh/pivotlow functions to find and identify new levels of basic support and resistance. The script will also automatically identify the first occurrence of a bounce/rejection off the most recent green/red line as well as automatically identify the first occurrence of a breakout of the most recent green/red line. This is a very basic, but effective indicator that is well written, and open source for anyone to learn from or build off of.
All details needed to understand how to use the script are listed below. Enjoy!
Customizable inputs:
- Option to change how pivot points are calculated('candle body' or 'candle wicks')
- Option to change the sensitivity of the pivots(leftbars and rightbars linked)
- Option to change the line width
Available Alert Options:
- Red Line Breakout
- Red Line Bounce/Rejection
- Green Line Breakout
- Green Line Bounce/Rejection
User Manual:
- All calculations are done on the last update of the bar(candle close)
- Only 1 breakout will be allowed per line
- Only 1 rejection will be allowed per line
- If the text is red, then the signal is related to the 'red line', if the text is green, then the signal is related to the 'green line'
- The code is open source, and is programmed using arrays/loops out of the gate, despite not needing to do so. This allows for easy modifications to the scripts behavior while keeping the functionality without it breaking.
- Pivot Rightbars is hardcoded to the same value for leftbars(leftbars = sensitivity). Uncomment the input for right_bars if you want the ability to change the rightbars independently from the leftbars
- When a new line is identified, the old one will stop updating, and no longer be considered for breakout/rejections. This can be changed with a bit of pine knowledge by performing some slight modifications to the code.
- When a new line is drawn, the old line will move backwards a little bit for cleanliness/clarity purposes
- If you have any questions/comments/requests/concerns please leave them down in the comments below
- Don't forget to leave a like if you find this script useful
RSI Failure Swings & AO DivergencesHello!
The script identifies RSI divergences, similar to other public scripts; however, RSI failure swings are also distinguished. When a failure swing is identified, the script calculates the highest RSI measurement (bottom failure swing) or the lowest RSI measurement (top failure swing) between the two RSI pivot points. A continually updating line is plotted at the "fail point" until it is penetrated for two sessions! In addition, the script displays the RSI fail point measurement. RSI bearish divergences are only distinguished when both RSI peaks form above 70. bullish divergences are only distinguished when both RSI troughs form below 30. Top failure swings require the initial RSI peak be above 70, the second RSI peak can form at any measurement. Bottom failure swings require the initial RSI trough be below 30, the second RSI trough can form at any measurement.
Included are Awesome Oscillator divergences. The indicator is a bit tricky; the oscillator does not incorporate an upper or lower extremity. Consequently, the script uses interpolated percentiles to characterize relatively high measurements and relatively low measurements. Bearish divergences that form within the 90th - 99th percentile are distinguished, and bullish divergences that form within the 1 - 10th percentile are distinguished. This can CERTAINLY be changed should you copy the source code and think of something better! For AO, white columns reflect a difference measurement >= 0; black bars reflect a difference measurement < 0
Advanced Comparison ToolWith the new Pine Script features you can build pretty interesting scripts.
Here is my try to expand functionality of basic comparison tool you have in TradingView.
When you apply it on your chart you can select a bar when do you want to start comparing your instrument from.
In parameters you can specify up to 32 symbols to compare. You can also disable symbols and change color for them as well.
As a result you'll see a table with summary and line for every instrument you selected as if it started from the close of the selected bar.
Disclaimer.
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as well as in historical backtesting.
This post and the script don’t provide any financial advice
Profit Percentage TrackerThis script provides a quick and easy way to visualize profits in a chart, based on the given entry date and price.
Optionally, alerts can be sent when profits cross up the given " profit unit ".
In short:
Tracks how much profit one could take based on the input " entry date " and the input " entry price "
These inputs are interactive (www.tradingview.com)
Displays the result in a label on top of the last candle
(Optional) Sends alerts based on the given " profit unit ", that is: if ' 0.5 ' is given, then an alert is triggered every time the profit is raised by that number
(Be careful with low values, as TradingView could stop an alert if it triggers too much.)
For alerts to be displayed, a " script alert " must be created right after the script was added to the chart:
- www.tradingview.com
(Choose ' Profits ' as condition and ' Any alert() function call ')
Good to know: if you check " Notify on app ", alerts can be delivered directly to your phone:
i.imgur.com
Prerequirements :
The chart's timezone has to be set to " Exchange " (this is required in order to support the alert's logic):
- kodify.net
TASC 2021.11 MADH Moving Average Difference, Hann█ OVERVIEW
Presented here is code for the "Moving Average Difference, Hann" indicator originally conceived by John Ehlers. The code is also published in the November 2021 issue of Trader's Tips by Technical Analysis of Stocks & Commodities (TASC) magazine.
█ CONCEPTS
By employing a Hann windowed finite impulse response filter (FIR), John Ehlers has enhanced the Moving Average Difference (MAD) to provide an oscillator with exceptional smoothness.
Of notable mention, the wave form of MADH resembles Ehlers' "Reverse EMA" Indicator, formerly revealed in the September 2017 issue of TASC. Many variations of the "Reverse EMA" were published in TradingView's Public Library.
█ FEATURES
Three values in the script's "Settings/Inputs" provide control over the oscillators behavior:
• The price source
• A "Short Length" with a default of 8, to manage the lower band edge of the oscillator
• The "Dominant Cycle", originally set at 27, which appears to be a placeholder for an adaptive control mechanism
Two coloring options are provided for the line's fill:
• "ZeroCross", the default, uses the line's position above/below the zero level. This is the mode used in the top version of MADH on this chart.
• "Momentum" uses the line's up/down state, as shown in the bottom version of the indicator on the chart.
█ NOTES
Calculations
The source price is used in two independent Hann windowed FIR filters having two different periods (lengths) of historical observation for calculation, one being a "Short Length" and the other termed "Dominant Cycle". These are then passed to a "rate of change" calculation and then returned by the reusable function. The secret sauce is that a "windowed Hann FIR filter" is superior tp a generic SMA filter, and that ultimately reveals Ehlers' clever enhancement. We'll have to wait and see what ingenuities Ehlers has next to unleash. Stay tuned...
The `madh()` function code was optimized for computational efficiency in Pine, differing visibly from Ehlers' original formula, but yielding the same results as Ehlers' version.
Background
This indicator has a sibling indicator discussed in the "The MAD Indicator, Enhanced" article by Ehlers. MADH is an evolutionary update from the prior MAD indicator code published in the October 2021 issue of TASC.
Sibling Indicators
• Moving Average Difference (MAD)
• Cycle/Trend Analytics
Related Information
• Cycle/Trend Analytics And The MAD Indicator
• The Reverse EMA Indicator
• Hann Window
• ROC
Join TradingView!
Run TimerThis is a simple utility which counts the number of bars and time elapsed after starting the script. This can be used in time or bars based conditions to modify script behavior.
This particular script does the following:
Starts timer when script is added to chart
Timer is green when starting and continues to be in green if the right Auth key is used in input (Which is hardcoded as 1234 here)
If right auth key is not provided in the input, timer background turns red after trial bars.
Script can be modified to use elapsed time instead.
Thanks to @Bjorgum on assisting on few calculations :)
Crypto Scannner for Traffic Lights StrategyI allways try to make trading easier. Developing Scripts for a quick backtest and improvement of a strategy, getting alerts for entry and exit a position. Loading data to a spreadsheet is also important and takes time.
In this case finding good parameters in different markets or assets to enter in a position, is a bit exhausting. It is something you have to do everyday, and sometimes in different moments of the day.
So I manage to develop a Screener, to take a quick look at specific hours, and tell if I have a buy or sell condition in an specific asset. Obviously this is not an alert to make a trade instantaneusly, but this help you filter a lot of information in matters of seconds. Then open those specific charts and make a better analisys.
A few weeks ago, I published a scrpipt called "Traffic Lights Strategy", that uses 4 emas to get a buy or a sell condition.
It is easy to understand and use, but if you don´t want to missed some opportunities, and don't want to be look at the screen in all the time looking for them, I have here a simple solution.
This script works plotting 2 labels. The first one plots all the assets in which the condition is true (fastema > medema > slowema > filterema or fastema < medema < slowema < filterema)
The second one plots the assets were the condition is true only if happened up to 5 candles back, so you can be in time to enter a trade.
You can take the script and customize it for a different strategy or assets. I coded like this because I backtested this strategy in this specific assets, and statistics suggest that it might be profitable.
I hope this works for you. In other time I'll try to code a script for the others strategies I published.
Multi-timeframe MAs + Stoch RSI SignalsHello traders,
I welcome you to my first published script on TradingView: “Multi-timeframe Moving Averages + Stochastic RSI”.
The script is based on a simple formula: Buy signals are generated when a fast moving average is above a slower moving average (uptrend) and the Stochastic RSI K line is crossing above the oversold level (entry).
Sell signals are generated when a fast moving average is below a slower moving average (downtrend) and the Stochastic RSI K line is crossing below the overbought level (entry).
This indicator works best in strong trends!
**Please note the above example has repainting turned on which may produce unrealistic results when viewing historical data. See below for more information regarding this and how you can turn it off.**
The user has the following inputs:
- Option to change the Stochastic RSI settings, including the oversold and overbought levels.
- Option to enter any value for both the Fast Moving Average and the Slow Moving Average.
- Option to change between EMA or SMA for each moving average.
- Multiple time frames to choose from, as well as the ability to selectively turn off individual time frames (both plots and alerts).
(Default time frames are 1 hour, 4 hour, and Daily. You can have a 4th time frame by changing your current time frame to something lower than the other 3 time frames)
- Turn on/off repainting: If repainting is turned on you will get an alert and buy/sell signal on chart immediately when condition is met, however the signal may disappear from chart if the condition reverses during the same candle.
If repainting is turned off, the indicator will wait for the candle to close before issuing the alert and painting the signal on chart.
For higher time frames, the indicator will wait for the candle in the higher time frame to close before issuing a signal if repaint is turned off. Default is set to Repaint on, so please be aware of this if you do not want repainting.
How to use alerts:
- Before you do anything, make sure your current time frame is the lowest time frame you’d like alerts on, as you will still receive alerts for the higher time frames you selected in settings.
- Once you have all the settings changed to how you like, save your chart first. Then right click on any of the indicator’s buy/sell signals on the chart and click “Add Alert on MAs + Stoch RSI”.
- Make sure “Any alert() function call” is selected under the Condition.
- You can delete or change the text in “Alert name” if you want as the alert message is already built into the indicator, and it will tell you in the alert message which asset and time frame to buy or sell.
Other things to note:
- The indicator will not display the buy/sell signals of lower time frames when you are on a higher time frame. This was done purposely to reduce clutter on the chart when you switch to higher time frames.
- While the alert message will tell you which time frame a signal was generated, the plots on the chart will instead show “Buy/Sell TF1, or TF2, or TF3”.
If the signal is from the current time frame that the alert was created on, then it will simply show “Buy” or “Sell”.
Hope you guys enjoy using this one, please drop a like if you found it useful. If anyone wants to modify my script in any way, please just credit me for the original work when you publish the script. Good luck!
PineGIF - Display Gifs & Images In Tradingview [LuxAlgo]Pinescript is not designed to create or display images, let alone gifs, but it's very fun to try, and that's what this script does. This script allows the user to display three different gifs. In this post, we explain how we managed to display images/gif's using pinescript tables.
1. Image Pre-Processing
Due to pinescript limitations, we can't possibly display images with an excessively high resolution. As such we targeted pixel art as a primary image source. We used a pixel art gif of the magnificent Octocat (the mascot for the source-code hosting service GitHub) for our first try.
We first extract each frame from the gif and resize them to a 50x50 resolution which returns frames made of 2500 pixels. This process was done using python.
Getting Individual Pixels RGBA Values
Python can easily return a matrix containing each pixel's rgba value. For convenience, we converted the rgba values to hex.
We then create a simple code allowing us to return a pinescript array containing the 2500 pixel hex colors. We do this process for each frame.
2. Defining Table Cell Color
In the code, each frame is its own array. We create a new table with dimensions equal to len(frame1)^2 (we assume height = width).
The color of a cell is defined by the color of the image pixel at the same exact location. When a new bar is created, we do this exact process using a different frame which ultimately allows a new frame to be displayed.
3. Playing The GIFs
By default, the script will play the gif of the Tradingview cloud logo raining. In order to play the gif, simply use the replay mode. The replay speed allows the user to determine the frame rate (0.1 for the raining cloud and Nyan cat works best, 0.5 for Octocat).
We included the frames of the Octocat and Nyan cat gifs in the script.
4. Some Other Cool Images
Displaying static images is possible and involves the same process described above.
An original idea of the lizard, implemented by the wizard.
CPR, Camarilla & Moving AverageThis script is created primarily for Intraday trading but can also be used for short and long term trading. This is a combination of Central Pivot Range (CPR), Moving Averages and Camarilla Pivot levels (with inner levels). This helps you to combine the strategies of CPR and Moving Averages to identify the best trading opportunities with greater edge. Central Pivot Range and Camarilla pivots are taken from PivotBoss by Franc Ochoa.
Key features:
# Daily CPR levels
# Weekly CPR levels
# Monthly CPR levels
# Previous Day High and Lows
# Previous Week Highs and Lows
# Previous Month Highs and Lows
# Camarilla Pivots with inner Levels
# CPR Levels for the next Day, Week and Month
# 5 Simple moving averages and 5 Exponential Moving Averages
What separates this script from other scripts with CPR and Moving averages?
# One of the few indicators (if not the only one) which combines the 2 types of Moving Averages, CPR and also Camarilla Pivots.
# CPR Levels for not just the next Day, but for next Week(Weekly CPR) and Month(Monthly CPR) also.
# Hide the previous day's levels according to your wish. This is the most unique feature of this indicator. You can set the number of Daily CPR levels you want to load in the chart. This is not just for the Daily CPR but also for the Weekly and Monthly CPR also. This makes the chart less cluttered and prevents the candles from getting buried in the indicators. Please notice how the previous day's CPR levels are hidden in the displayed demo chart on the script page. In the chart, only one trading day's data is shown(by default).
# This script is OPEN SOURCE.
Strategies :
For CPR & Camarilla Strategies for intraday trading and swing trading refer to the book 'Secrets of a Pivot Boss: Revealing Proven Methods for Profiting in the Market' by Franklin O. Ochoa.
Moving averages strategies :
Moving averages can be combined and also used individually for several strategies
* 9 EMA can be used as trailing stop loss for strong moving trends that helps you to catch big moves.
* 20sma can be used not just trailing stop loss but also for taking re-entry to the trend.
* Golden cross - The golden cross occurs when a short-term moving average crosses over a major long-term moving average to the upside. This indicates a bullish turn in the market. Eg: 50 SMA cuts 200 SMA from below.
* Death Cross - The death cross occurs when the short term moving average crosses the long-term average from above. This indicates a bearish turn in the market. Eg: 50 SMA cuts 200 SMA from above.
* When 20 SMA is above 50 SMA and 20 SMA and 50 SMA are angling up like parallel lines, then it denotes bullish strength. If this happens right after Golden Cross, big moves to the upside can be expected.
* When 20 SMA is below 50 SMA and 20 SMA and 50 SMA are angling down like parallel lines, then it denotes bearish strength. If this happens right after Death Cross, big moves to the downside can be expected.
* When 20SMA and 50 SMA are going flat and crossing each other, then it denotes sideways sentiment.
Moving average strategies are taken from the book 'How to Make Money in Intraday Trading' by Ashwani Gujral. For learning more about how to combine CPR and Moving averages in your trading please refer to this book.
INDIGO - SwingTraderThis is a script that uses a couple of other indicators to find good swing trade entry's and exit's. You can choose which signals the script uses to calculate the position of the signals.
It uses the following:
- Stoch RSI
- MACD
- POC
- INDIGO Cloud
Also added are volume candles, acceleration of momentum indicators (triangle) and MACD candles. This way you can see more info to decide if the entry is valid.
I have used a couple of public scripts and tried to give credit to the original creators. If there is any script that hasn't been credited, please contact me.
Feedback is very much appreciated, positive and negative. Also If you have any question, feel free to ask me. I'll try to answer asap.
Enjoy the script :)
SectorsThis script attempts to show the relative strength of the 11 sectors in the SPX, which can be accomplished in three ways:
1. Sectors - displays all sector indices as they appear normally
2. Sector Relativity - displays each sector divided by the sum of the other 10 sectors
3. Sector Alpha - displays the alpha of each sector as compared to the sum of the other 10 sectors
I have seen some other iterations of this script that compare each sector to the SPX as a whole, a couple problems with that:
1. SPX sector weightings are unequal and change quarterly, meaning you will get an inaccurate depiction of relative sector strength across time.
2. Even if using an equal-weight SPX, you would be comparing a sector to itself as all 11 sectors are included in the SPX, not just the complementary 10 you are looking to compare one sector to.
For more information on the sectors in the SPX or the calculation of Alpha, visit the links at the top of the script.
*Includes an option for repainting -- default value is true, meaning the script will repaint the current bar.
False = Not Repainting = Value for the current bar is not repainted, but all past values are offset by 1 bar.
True = Repainting = Value for the current bar is repainted, but all past values are correct and not offset by 1 bar.
In both cases, all of the historical values are correct, it is just a matter of whether you prefer the current bar to be realistically painted and the historical bars offset by 1, or the current bar to be repainted and the historical data to match their respective price bars.
As explained by TradingView,`f_security()` is for coders who want to offer their users a repainting/no-repainting version of the HTF data.
Random Synthetic Asset GenerationThis script generates pseudo-random asset data . Due to the nature of the random generator, it is impossible to use this indicator as input for other indicators because the instance of the script that the indicator is applied to will automatically be different from the instance that is plotted on the chart. Therefore, the idea is to use this script in other scripts (to make it possible to backtest on random data, for example).
The script has four main input parameters.
Random Number Generator Method: It supports two methods for generating the pseudo-random numbers (one by Ricardo Santos and one by Wichmann-Hill).
Seed: You can specify the seed to use. Each unique seed will generate a unique set of pseudo-random data.
Intrabar Volatility: This basically sets how volatile the generated wicks will be (0 = no wicks).
Price Multiplier: This is just a multiplier for the generated price data, so that you can scale up or down the generated price data.
You can also change the colors of the bars.
In addition to this, the indicator also generates random volume. In order to make it possible to show both volume and price, you need to have two identical instances of the indicator. One on the chart, and one in its own panel. Then, go into the Style tab in the indicator settings on the instance in the panel. Untick Up-Candles and Down-Candles boxes, and tick the Volume box.
In a similar manner, you can also plot the true range data and the candle change data as well, by ticking one of those boxes instead.
Hyper Frame Fibo MA RibbonsIntroduction
Moving averages are an integral part of the TA world. There are different types of moving averages and each person uses them depending on their strategy and market conditions.
Meanwhile, the main variable in calculating the averages is their LENGTH. This value is optional, but not every value is applicable.
After much experience in the world of financial markets, I came to the conclusion that although the most popular length values are 20, 50, 100, and 200, the Fibonacci number come with surprising results .
Description
The following script calculates seven averages with the length of Fibonacci numbers (34, 55, 89, 144, 233, 377 and 610) with the formula of your choice (SMA, EMA, WMA, HMA) and shows that we named it FiboMa .
You can also have Bollinger Bands with the desired frame at the same time.
This is not the whole story...
You can see the same values from smaller or larger frames at the same time!
We named this feature Hyper Frame Vision .
It is possible to display values for FiboMa up to three hyper frames (with the main frame a total of 4 levels) and in the Bollinger Bands one hyper frame (with the main frame a total of 2 levels).
By default, the display of FiboMa hyper frame values is limited to the last 10 bars, which you can change to an arbitrary value by changing the source code.
The display of hyper frame values is not limited for Bollinger Band.
What is its use? What is it good for?
Support and Resistance
Using dynamic support / resistance is much smarter than static! This protects you from the risk of many fake breaks, and your profit and loss limits will be more flexible and more efficient.
The intersection of FiboMa ribbons are potential points of support / resistance.
We use colors to easily identify supports / resistances.
Any average lower than the price is assumed as support and displayed in green, and any average above the price is assumed as resistance so displayed in red.
So the color of the averages is dynamic.
The color of FiboMa is a range from red to green. Whatever colors get saturated , the lenght is longer and the more power it has as support / resistance.
Volatility
With this script, you also have the ability to monitor the amount of market volatility ! The combination of Bollinger Bands and FiboMa provides a clear view of the market volatility.
The decrease and compression of the FiboMa width is a sign of a decrease in volatility and vice versa.
Trend
I don't see the need for additional explanation, only whenever the price is higher than the middle band , the BB cloud is green , and whenever it is lower , is red .
The wider FiboMa means the stronger trend.
How to use
In the script settings you have the ability to enable or disable anything except.
---------------------------------------------
Similar scripts have been published before and we were inspired by them and tried to improve idea and code uniqe one.
I hope it will be useful .. Support us with your likes and comments .. We have anothers great script .. Just started.
Candlestick Pattern FinderThis script identifies common candlestick patterns and marks them with a tool-tip on the chart. It is a compilation of Tradingview's built-in candlestick finding scripts so it uses the same rules defined by Tradingview to identify the patterns. Instead of using a separate indicator for each candlestick pattern, you can use this script to find all the candlestick patterns with a single indicator.
By default, the script does not mark any of the detected patterns on the chart. You will have to open the indicator settings and enable the patterns you would like to see on the chart. There are also three tick-boxes that let you to enable/disable all the selected bearish/bullish/neutral patterns at once, i.e. if you would like to only see bearish patterns, you can disable all the bullish and neutral patterns at once with the corresponding tick boxes. When you enable bullish patterns again, the script will show your selection of bullish patterns again on the chart.
When you hover on the tool-tips with your cursor, a short description about the pattern will be displayed.